package com.yuntsg.ruiijn.databse_search.service;

import com.yuntsg.ruiijn.databse_search.entity.NcbiPdfToJpg;
import com.yuntsg.ruiijn.databse_search.entity.TextParagraph;
import common.util.CentralRequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
@Slf4j

@SuppressWarnings("all")
public class BussService {
    @Autowired
    private CentralRequestUtil requestUtil;


    public NcbiPdfToJpg getImgData(Integer aid, String tableMark) {
        NcbiPdfToJpg imgData = requestUtil.getImgData(aid, tableMark);
        return Optional.ofNullable(imgData).orElse(new NcbiPdfToJpg().setPmidUt(""));
    }

    public TextParagraph getTextDomainById(String aid, String tableMark) {
        return requestUtil.getTextDomainById(aid, tableMark);

    }

    public String getTxtById(Integer segment, Integer sentence, String tableMark, Integer aid) {
        return requestUtil.getTxtById(segment, sentence, tableMark, aid);
    }

    public String getPreById(Integer segment, Integer sentence, String tableMark, Integer aid) {
        return requestUtil.getPreById(segment, sentence, tableMark, aid);
    }

    public String getNextById(Integer segment, Integer sentence, String tableMark, Integer aid) {
        return requestUtil.getNextById(segment, sentence, tableMark, aid);
    }


    public String getPmid(String tableMark, Integer aid) {
        String pmid = requestUtil.getPmid(tableMark, aid);
//        log.info("返回pmid+" + pmid);
        return pmid;
    }

    public String getUtPmid(String tableMark, Integer aid) {
        String utPmid = requestUtil.getUtPmid(tableMark, aid);
//        log.info("返回ut+" + utPmid);
        return utPmid;
    }

    public boolean saveOrUpdateBatch(String tableMark, List<NcbiPdfToJpg> list) {
        return requestUtil.saveOrUpdateBatch(tableMark, list);
    }

    public Integer saveOrUpdate(String tableMark, List<NcbiPdfToJpg> list) {
        return requestUtil.saveOrUpdate(tableMark, list);
    }
}
